<template>
  <div class="app-container">
    <div>
      <el-row class="admin-top-g">
        <GButton
          :is-add-show="false"
          :is-edit-show="!!(limits.length >=1 && limits.filter(it => it.FName === '修改').length)"
          :is-del-show="false"
          :is-send-sms-show="true"
          :lists="options"
          :is-settings-show = "lookSetShow"
          @onAdd="addUser"
          @onEdit="editUser"
          @onDelete="delUser"
          @selectSettings="selectSettings"
          @onSendSms="vxeSendSms"
      /></el-row>
      <br>

      <el-row class="common-row">
        <template v-if="limits.length >=1 && limits.filter(it => it.FName === '查看').length">
          <el-input v-model="keyword" clearable style="width: 260px;" placeholder="请输入关键字" @keyup.native.enter="searchUser" @change="searchUser"/>
          <el-select v-model="fisqr" clearable filterable style="width: 150px;" placeholder="请选择" @change="searchUser">
            <el-option
              v-for="item in fqrlist"
              :key="item.finterid"
              :label="item.fname"
              :value="item.finterid"/>
          </el-select>

          <!-- <el-select v-model="fstatus" clearable filterable style="width: 150px;" placeholder="请选择审核状态" @change="searchUser">
            <el-option
              v-for="item in statusList"
              :key="item.fstatus"
              :label="item.fname"
              :value="item.fstatus"/>
          </el-select> -->
          <el-button type="primary" icon="el-icon-search" @click="searchUser">搜索</el-button>
        </template>
        <!--
        <el-upload
          v-if="limits.length >=1 && limits.filter(it => it.FName === '导入').length"
          ref="uploadBasic"
          :on-preview="handlePreviewBasic"
          :on-remove="handleRemoveBasic"
          :limit="1"
          :data="upDataBasic"
          :on-exceed="exceedBasic"
          :on-success = "noticeBasic"
          :file-list="fileListBasic"
          :before-upload="beforeAvatarUploadBasic"

          class="upload-demo"
          style="display: inline-block; margin-left: 0px;"
          action="/excel/zyImport"
        >
          <el-button size="small" type="primary" icon="el-icon-upload">导入</el-button>
        </el-upload> -->

        <el-button v-if="limits.length >=1 && limits.filter(it => it.FName === '导出').length" type="primary" icon="el-icon-my-export" @click="downData">导出</el-button>
        <!--<el-button type="primary" icon="el-icon-my-updown" @click="handleDownload">下载{{ fmofanName }}模板</el-button>

        <el-button v-if="limits.length >=1 && limits.filter(it => it.FName === '审核').length" type="primary" icon="el-icon-circle-check" @click="check('1')">审核</el-button>
        <el-button v-if="limits.length >=1 && limits.filter(it => it.FName === '反审核').length" type="primary" icon="el-icon-close" @click="check('0')">反审</el-button> -->
        <el-button v-if="limits.length >=1 && limits.filter(it => it.FName === '确认').length" type="primary" icon="el-icon-chat-dot-round" @click="qrData(1)">确认</el-button>
        <el-button v-if="limits.length >=1 && limits.filter(it => it.FName === '退审').length" type="primary" icon="el-icon-close" @click="checkTs(0)">退审</el-button>
        <!-- <el-button type="primary" icon="el-icon-chat-dot-round" @click="qrData(0)">反确认</el-button> -->

        <el-button type="primary" icon="el-icon-refresh" @click="refresh">刷新 </el-button>
        <el-button
          v-if="limits.length >=1 && limits.filter(it => it.FName === '机型详情').length"
          type="primary"
          icon="el-icon-more"
          @click="toJxDetail">整机采购成本</el-button>

      </el-row>
    </div>
    <br>
    <el-table
      v-loading="listLoading"
      v-if="limits.length >=1 && limits.filter(it => it.FName === '查看').length"
      :data="tableData"
      :header-cell-class-name="markRed"
      :summary-method="getSummaries"
      :header-cell-style="tableHeaderStyle"
      :height="tableHeight"
      show-summary
      class="tableCss"
      element-loading-text="正在加载"
      border
      highlight-current-row
      @cell-dblclick="cellDbClick"
      @selection-change="handleSelectionChange"
      @current-change="salaryCurrentChange">
      <el-table-column
        type="selection"
        width="55"/>
      <template v-for="item in formThead">
        <el-table-column v-if="item.frpttypeflag ==0" :key="item.fid" :label="item.frepcap" :prop="item.frepfld" :width="item.frepwid" align="center" show-overflow-tooltip>

          <template slot-scope="scope">
            <template v-if="item.frephide<=0">
              <template v-if="item.frepfld === 'fstatus'">
                <el-tag v-if="Number(scope.row[item.frepfld]) === 1" size="mini" type="success">已审</el-tag>
                <el-tag v-else size="mini" type="danger">未审</el-tag>
              </template>
              <template v-else-if="item.frepfld === 'fisqrname'">
                <el-tag v-if="Number(scope.row[item.frepfld]) === 1" size="mini" type="success">已完成</el-tag>
                <el-tag v-else size="mini" type="danger">未完成</el-tag>
              </template>
              <template v-else size="mini">
                {{ scope.row[item.frepfld] }}
              </template>
            </template>
          </template>

        </el-table-column>
      </template>
    </el-table>

    <el-pagination
      v-if="limits.length >=1 && limits.filter(it => it.FName === '查看').length"
      :total="total"
      :page-sizes="pagesizes"
      :page-size="pagesize"
      :current-page.sync="currentPage"
      class="jy-pagination"
      style="text-align: center; margin-top: 20px;"
      background
      layout="sizes, prev, pager, next, total"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"/>

    <el-dialog v-el-drag-dialog :visible.sync="addUserModal" title="添加／编辑" width="30%">
      <hr style="height:1px;margin-top:-33px;border:none;border-top:1px solid #ddd;" >
      <el-form v-loading="loadingForm" ref="form" :rules="rules" :inline="true" :model="form" label-width="150px" class="form1">

        <el-row >
          <el-col v-for="item in dialogThead" :span="24" :key="item.fid ">

            <el-form-item :label="item.frepcap" :prop="item.frepfld" >
              <template v-if="item.frepmeg == 1">
                <template v-if=" 'funit' === item.frepfld" >
                  <el-select v-model="form[item.frepfld]" class="select_el" clearable filterable placeholder="请选择">
                    <el-option
                      v-for="item2 in fuzhujichu[item.frepfld]"
                      :key="item2.finterid"
                      :label="item2.fname"
                      :value="item2.fname"/>
                  </el-select>
                </template>

                <template v-else-if=" 'fbrand' === item.frepfld" >
                  <el-select v-model="form[item.frepfld]" class="select_el" clearable filterable placeholder="请选择">
                    <el-option
                      v-for="item2 in brandList"
                      :key="item2.finterid"
                      :label="item2.fname"
                      :value="item2.fname"/>
                  </el-select>
                </template>

              </template>
              <!-- 多文本-->
              <template v-else-if="item.frepmeg == 6" >
                <template >
                  <el-input :rows="3" v-model="form[item.frepfld]" type="textarea" />
                </template>
              </template>
              <!-- 日期框-->
              <template v-else-if="item.frepmeg == 4" >
                <template >
                  <el-date-picker v-model="form[item.frepfld]" style="width:100%" class="date_el" type="date" placeholder="选择日期" value-format="yyyy-MM-dd" />
                </template>
              </template>
              <!-- 禁止编辑-->
              <template v-else-if="item.frepmeg == 5" >
                <template >
                  <el-input v-model="form[item.frepfld]" :disabled="editText"/>
                </template>
              </template>

              <!-- 输入框 -->
              <template v-else >
                <el-input v-model="form[item.frepfld]" />
              </template>
            </el-form-item>
          </el-col>
        </el-row>

        <div class="dialog-footer">
          <el-form-item >
            <el-button :loading="loadingForm" type="primary" @click="confirm" >确认</el-button>
            <el-button @click="addUserModal=false">取消</el-button>
          </el-form-item>
        </div>
      </el-form>
    </el-dialog>

    <!-- 参数配置 -->
    <el-dialog v-el-drag-dialog :visible.sync="configModal" :close-on-click-modal="false" class="config-dialog">
      <head-table
        :config-list="configList"
        :key-value="key"
        @updateConfigData="getUpdateConfigData" />
    </el-dialog>

    <!-- SQL弹窗 -->
    <el-dialog v-el-drag-dialog :visible.sync="dialogSQLModal" :append-to-body="true" title="执行结果">
      <el-form v-loading="loadingFormSQL" ref="formSQL" :rules="rulesSQL" :model="formSQL" label-width="120px">
        <el-form-item label="SQL语句" prop="gzsql">
          <el-input v-model="formSQL.gzsql" :autosize="{ minRows: 14 }" type="textarea" style="width:400px;"/>
        </el-form-item>
        <el-form-item>
          <el-button :loading="loadingFormSQL" type="primary" @click="confirmSQL" >确认</el-button>
          <el-button @click="dialogSQLModal=false">取消</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>

    <!-- 下载模板 -->
    <el-dialog :visible.sync="tableSetExcel" title="提示：信息导出" style="width:30%; margin:auto;">
      <el-button type="primary" @click="downloadFile1()">导出</el-button>
    </el-dialog>

    <!-- SendMsg弹窗 -->
    <el-dialog v-el-drag-dialog :visible.sync="dialogSendMsgModal" :append-to-body="true" width="50%" title="发送信息">
      <el-tree
        ref="selectTree"
        :props="defaultProps"
        :data="sendUsrList"
        node-key="id"
        show-checkbox
        @node-click="handleNodeClick"/>
      <br>
      <el-form ref="formSendMsg" :rules="rulesSendMsg" :model="formSendMsg" label-width="40px">
        <el-form-item label="内容" prop="fcontent">
          <el-input v-model="formSendMsg.fcontent" :autosize="{ minRows: 5 }" type="textarea" />
        </el-form-item>
        <el-form-item>
          <el-button :loading="loadingFormSendMsg" type="primary" @click="confirmSendMsg">确认</el-button>
          <el-button @click="dialogSendMsgModal = false">取消</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>

    <!-- 公共弹窗 -->
    <el-dialog
      v-el-drag-dialog
      :visible.sync="fcomDialog.fmodal"
      :close-on-click-modal="false"
      :title= "fcomDialog.title"
      class="config-dialog detail-dialog fcom-dialog"
      @close="closeFcomDialog">
      <div v-if="fcomDialog.isShowToolBar" class="com-dialog-tool">
        <el-input v-model="fcomDialog.fcomKeyword" clearable style="width: 200px;" placeholder="请输入内容" />
        <el-select v-model="fcomDialog.fdanweibumen" clearable placeholder="请选择部门" @change="searchFcomData">
          <el-option
            v-for="item in fcomDialog.fdanweibumenList"
            :key="item.value"
            :label="item.label"
            :value="item.value"/>
        </el-select>
        <el-button type="primary" icon="el-icon-search" @click="searchFcomData">搜索</el-button>
        <el-button v-if="limits.length >= 1 && limits.filter(it => it.FName === '导出').length" type="primary" @click="exportDetailData(fcomDialog.title)">导出</el-button>
      </div>
      <el-table
        v-loading="fcomDialog.loading"
        id="fcomTable"
        ref="fcomTable"
        :summary-method="getJxSummaries"
        :header-cell-style="tableHeaderStyle"
        :data="fcomDialog.tableData"
        style="margin-top: 10px;"
        max-height="500"
        show-summary
        class="tableCss"
        element-loading-text="正在加载"
        border
        highlight-current-row>
        <el-table-column
          v-for="(item, key) in fcomDialog.formThead"
          :key="key"
          :prop="item"
          :label="item"
          align="center">
          <template slot-scope="scope">{{ scope.row[item] }}</template>
        </el-table-column>
      </el-table>
    </el-dialog>

    <el-dialog
      v-el-drag-dialog
      :visible.sync="confirmVisible"
      :close-on-click-modal="false"
      class="confirm-dialog"
      title="确认信息"
      width="30%">
      <p class="description">业务部门需求，请确认？</p>
      <span slot="footer" class="dialog-footer">
        <el-button @click="confirmVisible = false">取 消</el-button>
        <el-button type="primary" @click="confirmQrData">确 定</el-button>
      </span>
    </el-dialog>

    <el-dialog
      v-el-drag-dialog
      :visible.sync="jzVisible"
      :close-on-click-modal="false"
      class="confirm-dialog"
      title="机型详情"
      width="50%"
    >
      <div class="dialog-container" style="overflow:hidden">
        <div class="search-jx" style="display: flex;">
          <el-input
            v-model="keywordcg"
            clearable
            size="mini"
            placeholder="搜索"
            style="width: 160px;float: left; margin-top: 10px; margin-right: 6px;z-index: 100000"
            @keyup.native.enter="jxSearch"
            @change="jxSearch"
          />
          <el-button size="mini" type="primary" @click="jxSearch">搜索</el-button>
        </div>
        <br>
        <el-table
          v-loading="jzLoading"
          v-if="limits.length >=1 && limits.filter(it => it.FName === '查看').length"
          :data="jzData"
          :header-cell-style="tableHeaderStyle"
          :header-cell-class-name="markRed"
          :summary-method="getJxSummaries"
          class="tableCss"
          max-height="450"
          show-summary
          element-loading-text="正在加载"
          border
          highlight-current-row>
          <el-table-column
            v-for="(item, key) in jzFormThead"
            :key="key"
            :prop="item"
            :label="item"
            align="center"
            show-overflow-tooltip>
            <template slot-scope="scope">{{ scope.row[item] }}</template>
          </el-table-column>
        </el-table>
        <div class="table-total">
          <div class="sum_footer">
            <span class="total">含税合计</span>
            <span class="mid" />
            <span class="sum">{{ (fcomDialog.total * 1.13).toFixed(2) || '' }}</span>
          </div>
        <!-- <div class="sum_footer">
          <span class="total">合计</span>
          <span class="mid" >-</span>
          <span class="sum">{{ total * 1.13 }}</span>
        </div> -->
        </div>
      </div>
    </el-dialog>

  </div>
</template>
<script>
let FRepKey = ''
let opername = ''
const defaultFormThead = []

import HeadTable from '../salary/headTable/index.vue'
import { configColumn, checkStatus, FstatusTS, ywQR } from '../../api/salary'
import { brand } from '../../mixins/brand'
import { download } from '../../mixins/download.js'
import { common } from '../../mixins/common'
import { pagination } from '../../mixins/pagination'
import { parseTime } from '../../utils/index'
import { tableConfig, apiSql, getCBData, apiFileSave, downFileUrl } from '../../api/account'
import { genAdd, genDel, genList } from '../../api/gen'
import { sendsms, beijianTree } from '../../api/peijian'
import { getZSBaoJiaMX } from '../../api/xmbj'
import { XLSXOBJ } from '../../utils/XLSXExportExcel'
import '../../styles/common.scss'
import '../../styles/svg.scss'

export default {
  name: 'Index',
  components: {
    HeadTable
  },
  filters: {
    parseTime(time, type) {
      return parseTime(time, type)
    }
  },
  mixins: [download, common, pagination, brand],
  data() {
    return {
      fstatus: '', // 状态
      // 下拉列表
      statusList: [
        {
          fstatus: 0,
          fname: '全部'
        },
        {
          fstatus: 1,
          fname: '未审'
        },
        {
          fstatus: 2,
          fname: '已审'
        }
      ],
      isQr: 0, // 确认、反确认
      confirmVisible: false,
      // 明细公共弹窗
      fcomDialog: {
        info: [
          { field: 'fjiazhangcbcg', title: '加账采购详情', FRepKey: 26005, fdanweibumen: 1, isShowToolBar: true },
          { field: 'fjiazhangcbjs', title: '加账技术详情', FRepKey: 26023, fdanweibumen: 2, isShowToolBar: true },
          { field: 'fjiazhangcbqt', title: '加账其他详情', FRepKey: 26025, fdanweibumen: 3, isShowToolBar: true },
          { field: 'fisjiazhang', title: '是否有加账详情', FRepKey: 14012, fdanweibumen: 0, isShowToolBar: true }

        ],
        row: {},
        fcomKeyword: '',
        fbrand: '',
        fbrandList: [
          { label: 'WINGD', value: 'WINGD' },
          { label: 'MAN', value: 'MAN' }
        ],
        fdanweibumen: 0,
        fdanweibumenList: [
          { label: '采购部', value: 1 },
          { label: '技术中心', value: 2 },
          { label: '其他部门', value: 3 },
          { label: '全部', value: 0 }
        ],
        total: 0,
        fjzdetail: 1, // 是否加账处理
        FRepKey: 0,
        isShowToolBar: false,
        title: '',
        fjybjbillno: '',
        keyword: '',
        fmodel: '',
        fmodal: false,
        loading: false,
        tableData: [],
        formThead: []
      },

      dialogSendMsgModal: false,
      loadingFormSendMsg: false,
      userList: [],
      sendUsrList: [],
      formSendMsg: {
      },
      rulesSendMsg: {
      },
      defaultProps: {
        children: 'children',
        label: 'label'
      },
      handleNodeClick(data) {
        console.log(data)
      },
      fisqr: 0,
      fqrlist: [
        {
          finterid: 0,
          fname: '未确认'
        },
        // {
        //   finterid: 1,
        //   fname: '确认中'
        // },
        {
          finterid: 2,
          fname: '已确认'
        },
        {
          finterid: 5,
          fname: '已完成'
        }
      ],
      value: '',
      options: [],
      FRepKey: '',
      keyword: '',
      fdeleted: '',
      fdeletedList: [

      ],
      fdeletedListDiaL: [

      ],
      gapTime: '',
      start_time: '',
      end_time: '',

      // 表头、表格设置
      tableData: [],
      tableList: [],
      defaultFormThead: [],
      formThead: defaultFormThead,
      dialogThead: [],
      curData: {},

      listLoading: false,
      list: [],
      configModal: false,
      configLoading: false,

      loadingForm: false,
      configList: [],
      key: 0,
      // SQL弹窗
      dialogSQLModal: false,
      loadingFormSQL: false,
      formSQL: {
        gzsql: ''
      },
      rulesSQL: {

      },

      form: {},
      rules: {

      },
      addUserModal: false,
      // loadingForm: false

      fileList: [],

      // 批量删除
      checkData: [],
      selectedData: [],

      // 用户菜单
      menusList: [],
      limits: [],
      fuzhujichu: {},
      userKey: '',
      fmofanName: '',

      bmwzList: [ // 部门位置
        {
          finterid: 0,
          fname: '钢壳'
        },
        {
          finterid: 1,
          fname: '铝壳'
        },
        {
          finterid: 2,
          fname: '14500'
        }
      ],

      upData: {},
      fdeptname: '', // 部门
      bmList: [], // 部门
      xlList: [], // 学历
      zwList: [], // 职务
      xbList: [], // 性别
      lzztList: [],
      fileListBasic: [],
      baseList: [],
      upDataBasic: {},

      detail: '',
      opername: '',
      detailVisible: false,
      editText: false,
      tableSetExcel: false,
      lookSetShow: false,
      oriColumnData: [],
      setConfigData: [],

      jzLoading: false,
      jzVisible: false,
      keywordcg: '',
      jxFbrand: '',
      jxFmodel: '',
      jxFRepKey: '',
      jzFormThead: [],
      jzData: []

    }
  },
  async mounted() {
    this.userKey = this.$route.meta.FRepKey
    FRepKey = this.$route.meta.FRepKey
    this.upDataBasic.db = this.globalDb.db
    opername = decodeURIComponent(this.globalDb.fname)
    this.opername = decodeURIComponent(this.globalDb.fname)

    this.upDataBasic.FRepKey = this.$route.meta.FRepKey
    this.lookSetShow = JSON.parse(localStorage.getItem('flookSet'))

    this.upData.db = this.globalDb.db
    this.fmofanName = this.$route.meta.title

    await this.getAllData()
    // 获取单位
    // await this.getunit()

    // 菜单列表（权限）
    const menuRes = JSON.parse(localStorage.getItem('setMenuData'))
    this.menusList = menuRes
    if (menuRes.length >= 1) {
      menuRes.map(it => {
        it.children.map(item => {
          if (item.fobjectid === this.userKey) {
            this.$set(this, 'limits', item.child)
          }
        })
      })
    }

    // 获取辅助资料
    const fuzhujichu = JSON.parse(localStorage.getItem('fuzhujichuData'))
    this.$set(this, 'fuzhujichu', fuzhujichu)
    // 参数设置
    const setConfigData = JSON.parse(localStorage.getItem('setConfigData'))
    this.$set(this, 'setConfigData', setConfigData)
    // console.log(setConfigData.fsethuilv)
  },
  methods: {
    markRed({ row, rowIndex, column, columnIndex }) {
      let markRed = ''
      switch (column.property) {
        case 'fisjiazhang': // 是否有加账
          markRed = 'markRed'
          break
        default:
          markRed = ''
          break
      }
      return markRed
    },

    async cellDbClick(row, column, cell, event) {
      // console.log(column.id, column.property, column, row, event, 'column')
      // fcomDialog
      switch (column.property) {
        case 'fisjiazhang':
          this.fcomDialog.fmodel = row.fmodel
          this.fcomDialog.fbrand = row.fbrand
          this.fcomDialog.fjybjbillno = row.fbillno
          this.fcomDialog.row = row
          this.fcomDialog.fmodal = true
          this.fcomDialog.info.map(item => {
            if (item.field === column.property) {
              this.fcomDialog.isShowToolBar = item.isShowToolBar
              this.fcomDialog.title = item.title
              this.fcomDialog.FRepKey = item.FRepKey
              this.fcomDialog.fdanweibumen = item.fdanweibumen
            }
          })

          await this.getJZBAOJIAMX({
            keyword: this.fcomDialog.fcomKeyword,
            FRepKey: this.fcomDialog.FRepKey,
            opername,
            data: this.fcomDialog.row,
            fdanweibumen: this.fcomDialog.fdanweibumen,
            fbrand: this.fcomDialog.fbrand,
            fmodel: this.fcomDialog.fmodel,
            fjzdetail: this.fcomDialog.fjzdetail,
            fjybjbillno: this.fcomDialog.fjybjbillno
          })

          break
        default:
          break
      }
    },
    async searchFcomData() {
      const data = {
        keyword: this.fcomDialog.fcomKeyword,
        FRepKey: this.fcomDialog.FRepKey,
        opername,
        data: this.fcomDialog.row,
        fbillnoentry: this.fcomDialog.fbillnoentry,
        fdanweibumen: this.fcomDialog.fdanweibumen,
        fbrand: this.fcomDialog.fbrand,
        fmodel: this.fcomDialog.fmodel,
        fjzdetail: this.fcomDialog.fjzdetail,
        fjybjbillno: this.fcomDialog.fjybjbillno
      }
      await this.getJZBAOJIAMX(data)
    },
    async getJZBAOJIAMX(data) {
      try {
        this.fcomDialog.loading = true
        // const res = await JZBAOJIAMX(data)
        // const res = await BAOJIAMX(data)
        const res = await getZSBaoJiaMX(data)

        if (res.Error === 0) {
          if (res.Data.length) {
            this.fcomDialog.formThead = Object.keys(res.Data[0])
          } else {
            this.fcomDialog.formThead = []
          }
          setTimeout(() => {
            this.fcomDialog.tableData = res.Data
          }, 0)
          this.fcomDialog.loading = false
        }
        // this.key = FRepKey
      } catch (error) {
        this.fcomDialog.loading = false
      }
    },
    closeFcomDialog() {
      this.fcomDialog.fcomKeyword = ''
      this.fcomDialog.title = ''
      this.fcomDialog.FRepKey = 0
      this.fcomDialog.fdanweibumen = ''
      this.fcomDialog.fbrand = ''
      this.fcomDialog.fmodel = ''
      this.fcomDialog.fjybjbillno = ''
      this.fcomDialog.fmodal = false
    },
    exportDetailData(filename) {
      XLSXOBJ.ExportExcelData(['fcomTable'], filename)
    },
    async confirmQrData() {
      const val = this.isQr
      if (Number(val) === 1) {
        if (this.fisqr >= 1) {
          this.$message({
            message: '已确认过了，无法再确认!!',
            type: 'error'
          })
          return
        }

        const res = await ywQR({ FRepKey, fisqr: val, data: this.selectedData, opername: decodeURIComponent(this.globalDb.fname), fid: this.checkData.join(',') })
        if (res.Error === 0) {
          this.$message({
            type: 'success',
            message: res.Message
          })
          this.confirmVisible = false
          await this.getAllData()
        } else if (Number(res.Error) === 14009) {
          this.$confirm(res.Message + '请重新确认？', '重新确认', {
            type: 'error',
            distinguishCancelAndClose: true,
            confirmButtonText: '确认',
            cancelButtonText: '放弃确认'
          })
            .then(async() => {
              const res = await ywQR({ FRepKey, fisqr: val, fisrqr: 1, data: this.selectedData, opername: decodeURIComponent(this.globalDb.fname), fid: this.checkData.join(',') })
              if (res.Error === 0) {
                this.$message({
                  type: 'success',
                  message: res.Message
                })
                await this.getAllData()
              } else {
                this.$message({
                  type: 'error',
                  message: res.Message
                })
              }
              this.confirmVisible = false
            })
            .catch(action => {
              this.$message({
                type: 'info',
                message: action === 'cancel'
                  ? '放弃确认'
                  : '停留在当前页面'
              })
            })
        } else {
          this.$message({
            type: 'error',
            message: res.Message
          })
          this.confirmVisible = false
        }
      } else {
        this.$confirm('业务部门需求，请确认？', '确认信息', {
          distinguishCancelAndClose: true,
          confirmButtonText: '反确认',
          cancelButtonText: '放弃反确认'
        })
          .then(async() => {
            const res = await ywQR({ FRepKey, data: this.selectedData, fisqr: val, opername: decodeURIComponent(this.globalDb.fname), fid: this.checkData.join(',') })
            if (res.Error === 0) {
              this.$message({
                type: 'success',
                message: '反确认成功'
              })
              await this.getAllData()
            } else {
              this.$message({
                type: 'error',
                message: res.Message
              })
            }
          })
          .catch(action => {
            this.$message({
              type: 'info',
              message: action === 'cancel'
                ? '放弃反确认'
                : '停留在当前页面'
            })
          })
      }
    },
    // 确认
    qrData(val) {
      if (!this.checkData.length) {
        this.$message({
          message: '请选择表格行数据',
          type: 'error'
        })
        return
      }
      this.confirmVisible = true
      this.isQr = val
      // if (Number(val) === 1) {
      //   if (this.fisqr >= 1) {
      //     this.$message({
      //       message: '已确认过了，无法再确认!!',
      //       type: 'error'
      //     })
      //     return
      //   }
      //   this.$confirm('业务部门需求，请确认？', '确认信息', {
      //     distinguishCancelAndClose: true,
      //     confirmButtonText: '确认',
      //     cancelButtonText: '放弃确认'
      //   })
      //     .then(async() => {
      //       const res = await ywQR({ FRepKey, fisqr: val, data: this.selectedData, opername: decodeURIComponent(this.globalDb.fname), fid: this.checkData.join(',') })
      //       if (res.Error === 0) {
      //         this.$message({
      //           type: 'success',
      //           message: res.Message
      //         })
      //         await this.getAllData()
      //       } else {
      //         this.$message({
      //           type: 'error',
      //           message: res.Message
      //         })
      //       }
      //     })
      //     .catch(action => {
      //       this.$message({
      //         type: 'info',
      //         message: action === 'cancel'
      //           ? '放弃确认'
      //           : '停留在当前页面'
      //       })
      //     })
      // } else {
      //   this.$confirm('业务部门需求，请确认？', '确认信息', {
      //     distinguishCancelAndClose: true,
      //     confirmButtonText: '反确认',
      //     cancelButtonText: '放弃反确认'
      //   })
      //     .then(async() => {
      //       const res = await ywQR({ FRepKey, data: this.selectedData, fisqr: val, opername: decodeURIComponent(this.globalDb.fname), fid: this.checkData.join(',') })
      //       if (res.Error === 0) {
      //         this.$message({
      //           type: 'success',
      //           message: res.Message
      //         })
      //         await this.getAllData()
      //       } else {
      //         this.$message({
      //           type: 'error',
      //           message: res.Message
      //         })
      //       }
      //     })
      //     .catch(action => {
      //       this.$message({
      //         type: 'info',
      //         message: action === 'cancel'
      //           ? '放弃反确认'
      //           : '停留在当前页面'
      //       })
      //     })
      // }
    },
    // 刷新
    refresh() {
      window.location.reload()
    },
    async jxSearch() {
      await this.getJxData()
    },
    async toJxDetail() {
      if (!this.checkData.length) {
        this.$message({
          message: '请选择表格行数据',
          type: 'error'
        })
        return
      }
      // console.log(this.selectedData, ' this.selectedData')
      // return
      this.jxFbrand = ''
      this.jxFmodel = ''
      this.keywordcg = ''
      this.jxFRepKey = ''
      this.jzVisible = true
      const selected = this.selectedData[0]
      this.jxFbrand = selected.fbrand
      this.jxFmodel = selected.fmodel
      if (selected.fbrand === 'MAN') {
        this.jxFRepKey = 26022
      } else {
        this.jxFRepKey = 26009
      }
      await this.getJxData()
    },
    async getJxData() {
      try {
        this.jzLoading = true
        const res = await getCBData({
          FRepKey: this.jxFRepKey,
          db: this.globalDb.db,
          fdanweibumen: '',
          fbrand: this.jxFbrand,
          fmodel: this.jxFmodel,
          keyword: '',
          keywordcg: this.keywordcg,
          opername
          // fjzdetail: selected.fjzdetail,
          // fjybjbillno: selected.fbillno
        })
        console.log(res, '  res')
        if (res.Error === 0) {
          if (res.Data.length) {
            this.jzFormThead = Object.keys(res.Data[0])
          } else {
            this.jzFormThead = []
          }
          setTimeout(() => {
            this.jzData = res.Data
          }, 0)
        } else {
          this.$message({
            type: 'error',
            message: res.Message
          })
        }
        this.jzLoading = false
      } catch (error) {
        this.jzLoading = false
        console.log(error)
      }
    },
    getJxSummaries({ columns, data }) {
      const sums = []
      columns.forEach((column, columnIndex) => {
        if (columnIndex === 0) {
          sums[columnIndex] = '合计'
        } else {
          // if (arr.indexOf(column.property) >= 0) {
          //   sums[columnIndex] = this.sumNum(data, column.property).toFixed(2)
          // } else {
          //   sums[columnIndex] = ''
          // }
          // const values = data.map(item => Number(item[column.property]))
          const values = data.map(item => {
            if (item[column.property] !== '') {
              if (!isNaN(item[column.property])) {
                return Number(item[column.property])
              }
            }
          })
          if (!values.every(value => isNaN(value))) {
            sums[columnIndex] = values.reduce((prev, curr) => {
              const value = Number(curr)
              if (!isNaN(value)) {
                return ((prev + curr) * 100) / 100
              } else {
                return (prev * 100) / 100
              }
            }, 0)
            // sums[columnIndex] += ' '
            sums[columnIndex] = sums[columnIndex].toFixed(2)
          } else {
            sums[columnIndex] = ''
          }
        }
      })
      // 返回一个二维数组的表尾合计
      const sum2 = Number(sums[sums.length - 1]).toFixed(2)
      // sums[sums.length - 1] = sum2
      console.log(sum2, ' sum2')
      if (isNaN(sum2)) {
        this.fcomDialog.total = ''
      } else {
        this.fcomDialog.total = sum2
      }
      return sums
    },
    async vxeSendSms() {
      if (this.selectedData.length !== 1) {
        this.$message({
          message: '请选中要通知的一行',
          type: 'error'
        })
        return
      }
      this.dialogSendMsgModal = true
      await this.getBeijianTree()
    },
    async getBeijianTree() {
      try {
        this.sendMsgLoading = true
        const res = await beijianTree({
          opername: decodeURIComponent(this.globalDb.fname)
        })
        console.log(res, ' res')
        this.sendUsrList = res.Data
        this.sendMsgLoading = false
      } catch (error) {
        this.sendMsgLoading = false
        console.log(error)
      }
    },
    async confirmSendMsg() {
      const selectMsgArr = this.$refs.selectTree.getCheckedKeys(true)
      console.log(selectMsgArr, ' selectMsgArr')
      // this.dialogSendMsgModal = true
      try {
        const fcontent = this.formSendMsg.fcontent
        const fbillno = this.selectedData[0].fbillno
        if (selectMsgArr.length) {
          const fid = selectMsgArr.join(',')
          if (!fid) {
            this.$message({
              message: '手机号为空',
              type: 'error'
            })
            return
          }
          const res = await sendsms({
            opername: decodeURIComponent(this.globalDb.fname),
            fid,
            fcontent,
            fbillno
          })
          console.log(res, ' res')
          if (res.Error === 0) {
            this.mulSendMsgSelect = []
            this.formSendMsg.fcontent = ''
            this.dialogSendMsgModal = false
          }
        } else {
          this.$message({
            message: '未选中发送信息通知人员',
            type: 'error'
          })
          return
        }
      } catch (error) {
        this.dialogSendMsgModal = false
      }
    },
    async toDetail(data) {
      this.detailVisible = true
      this.detail = data
    },

    selectFBirthday(val) {
      this.form.fbirthday = parseTime(val, '{y}-{m}-{d}')
    },
    selectFHireDate(val) {
      this.form.fhiredate = parseTime(val, '{y}-{m}-{d}')
    },
    selectFLeaveDate(val) {
      this.form.fleavedate = parseTime(val, '{y}-{m}-{d}')
    },
    // -----------------上传开始---------------------
    beforeAvatarUpload(file) {
      var testmsg = file.name.substring(file.name.lastIndexOf('.') + 1)
      const extension = testmsg === 'xls' || testmsg === 'xlsx'
      const isLt2M = file.size / 1024 / 1024 < 1
      if (!extension) {
        this.$message({
          message: '上传文件只能是 xls/xlsx格式!',
          type: 'warning'
        })
      }
      if (!isLt2M) {
        this.$message({
          message: '上传文件大小不能超过 1MB!',
          type: 'warning'
        })
      }

      const fd = new FormData()
      fd.append('file', file)

      if (extension) {
        return true
      } else {
        this.$message.warning('只能上传excel文件格式xls/xlsx')
        return false
      }
    },

    async submitUpload() {
      this.$refs.upload.submit()
    },

    handleRemove(file, fileList) {

    },
    handlePreview(file) {

    },
    exceed() {
      // 重复选择文件,弹出错误弹窗
      this.$message('最多仅支持上传一个文件')
    },
    notice(e) {
      if (e.code === 200) {
        this.$message(e.message)
      } else {
        this.$message(e.message)
      }
    },
    // -----------------上传结束---------------------
    // 表头数据
    async getAllHeadData() {
      try {
        this.listLoading = true
        this.header = []
        this.headerKeys = []
        this.listData = []
        const res = await configColumn({
          db: this.globalDb.db,
          opername,
          FRepKey
        })
        this.listLoading = false
        this.formThead = res.Data
        this.oriColumnData = res.Data

        // this.tableList = []
        this.formThead.map(item => {
          this.tableList.map(it => {
            if (item.freptype === 131) {
              it[item.frepfld] = Number(it[item.frepfld]).toFixed(item.fdecplaces)
            }
          })
        })
        // this.tableData = this.tableList.slice()
        let tableTemp
        if (this.selectedData.length) {
          tableTemp = this.selectedData
        } else {
          tableTemp = this.tableList.slice()
        }

        // 获取显示表头键值对
        this.formThead.filter(item => {
          if (!item.frephide) {
            this.header.push(item.frepcap)
            this.headerKeys.push(item.frepfld)
          }
        })
        // 获取显示表体数据
        // const listData = this.tableList.slice()
        const listData = tableTemp.slice()
        listData.map((item, index) => {
          this.listData[index] = {}
          this.headerKeys.map(it => {
            this.listData[index][it] = item[it]
          })
        })

        // 去除内码
        const arr = res.Data.slice()
        arr.map((item, index) => {
          if (item.frepfld === 'fid') {
            arr.splice(index, 1)
          }
        })

        this.dialogThead = arr.filter(item => item.funcontrol !== 1)
      } catch (error) {
        this.listLoading = false
      }
    },

    // 表体数据————erp职员列表
    async getAllBodyData() {
      try {
        this.listLoading = true
        const res = await genList({
          db: this.globalDb.db,
          opername,
          keyword: this.keyword,

          fstatus: this.fstatus,
          fisqr: this.fisqr,
          limit: this.total,
          page: this.currentPage,
          FRepKey
        })
        this.listLoading = false

        this.tableList = res.Data
        this.total = res.total
      } catch (error) {
        this.listLoading = false
      }
    },
    // 导出数据
    async downData() {
      await this.getAllBodyData()
      await this.getAllHeadData()
      await this.exportData()
    },
    async getAllData() {
      await this.getBodyData()
      await this.getHeadData()
    },

    selectSettings(val) {
      if (val === 0) {
        this.settings()
      } else if (val === 1) {
        this.dialogSQL()
      }
    },
    settings() {
      this.configModal = true
      this.getTableConfig()
    },

    // 更新数据
    async getUpdateConfigData() {
      await this.getTableConfig()
      await this.getBodyData()
      await this.getHeadData()
    },

    // SQL修改/更新
    async dialogSQL() {
      this.dialogSQLModal = true
      try {
        const res = await apiSql({
          db: this.globalDb.db,
          opername,
          FRepKey
        })

        if (res.Error === 0) {
          this.formSQL.gzsql = res.Data
          this.formSQL.FRepKey = FRepKey
        }
        setTimeout(() => {
          this.$refs['formSQL'].clearValidate()
        })
      } catch (error) {
        // console.log(error)
      }
    },

    confirmSQL() {
      this.$refs['formSQL'].validate(async(valid) => {
        if (valid) {
          try {
            this.formSQL.db = this.globalDb.db
            this.formSQL.opername = opername
            const res = await apiFileSave(this.formSQL)
            if (res.Error === 0) {
              this.dialogSQLModal = false
              this.$message({
                message: res.Message,
                type: 'success'
              })
            } else {
              this.$message({
                message: res.Message,
                type: 'error'
              })
            }
          } catch (error) {
            // console.log(error)
          }
        } else {
          return false
        }
      })
    },

    // 设置表格字段--获取数据
    async getTableConfig() {
      try {
        this.configLoading = true
        const res = await tableConfig({
          db: this.globalDb.db,
          opername,
          key: FRepKey
        })

        this.configList = res.Data

        this.key = FRepKey
        this.configLoading = false
      } catch (error) {
        this.configLoading = false
      }
    },

    // 表头数据
    async getHeadData() {
      try {
        this.listLoading = true
        this.header = []
        this.headerKeys = []
        this.listData = []
        const res = await configColumn({
          db: this.globalDb.db,
          opername,
          FRepKey
        })
        this.listLoading = false
        this.formThead = res.Data
        this.oriColumnData = res.Data

        // this.tableList = []
        this.formThead.map(item => {
          this.tableList.map(it => {
            if (item.freptype === 131) {
              it[item.frepfld] = Number(it[item.frepfld]).toFixed(item.fdecplaces)
            }
          })
        })
        this.tableData = this.tableList.slice()

        // 获取显示表头键值对
        this.formThead.filter(item => {
          if (!item.frephide) {
            this.header.push(item.frepcap)
            this.headerKeys.push(item.frepfld)
          }
        })
        // 获取显示表体数据
        const listData = this.tableList.slice()
        listData.map((item, index) => {
          this.listData[index] = {}
          this.headerKeys.map(it => {
            this.listData[index][it] = item[it]
          })
        })

        // 去除内码
        const arr = res.Data.slice()
        arr.map((item, index) => {
          if (item.frepfld === 'fid') {
            arr.splice(index, 1)
          }
        })

        this.dialogThead = arr.filter(item => item.funcontrol !== 1)
      } catch (error) {
        this.listLoading = false
      }
    },

    // 表体数据————erp职员列表
    async getBodyData() {
      try {
        this.listLoading = true
        const res = await genList({
          db: this.globalDb.db,
          opername,
          keyword: this.keyword,

          fstatus: this.fstatus,
          fisqr: this.fisqr,
          limit: this.pagesize,
          page: this.currentPage,
          FRepKey
        })
        this.listLoading = false

        this.tableList = res.Data
        this.total = res.total
      } catch (error) {
        this.listLoading = false
      }
    },

    async searchUser() {
      await this.getAllData()
    },
    async handleSizeChange(val) {
      this.currentPage = 1
      this.pagesize = val
      await this.getAllData()
    },
    async handleCurrentChange(val) {
      this.currentPage = val
      await this.getAllData()
    },
    salaryCurrentChange(val) {
      this.curData = val
    },

    // 下载
    async handleDownload() {
      const res = await downFileUrl({
        db: this.globalDb.db,
        opername,
        FRepKey
      })
      if (res.Error === 0) {
        this.tableSetExcel = true
        this.url = res.Data
      } else {
        this.$message({
          message: res.Message,
          type: 'error'
        })
      }
    },

    downloadFile1() {
      this.tableSetExcel = false
      window.open('/api/downloadFile?FRepKey=' + FRepKey)
    },

    // -----------------上传模板开始---------------------
    beforeAvatarUploadBasic(file) {
      var testmsg = file.name.substring(file.name.lastIndexOf('.') + 1)
      const extension = testmsg === 'xls' || testmsg === 'xlsx'
      const isLt2M = file.size / 1024 / 1024 < 1
      if (!extension) {
        this.$message({
          message: '上传文件只能是 xls/xlsx格式!',
          type: 'error'
        })
      }
      if (!isLt2M) {
        this.$message({
          message: '上传文件大小不能超过 1MB!',
          type: 'error'
        })
      }

      const fd = new FormData()
      fd.append('file', file)

      if (extension) {
        return true
      } else {
        this.$message.warning('只能上传excel文件格式xls/xlsx')
        return false
      }
    },

    async submitUploadBasic() {
      this.$refs.uploadBasic.submit()
    },

    handleRemoveBasic(file, fileList) {

    },
    handlePreviewBasic(file) {

    },
    exceedBasic() {
      // 重复选择文件,弹出错误弹窗
      this.$message('最多仅支持上传一个文件')
    },

    noticeBasic(e) {
      if (e.Error === 0) {
        this.$message(e.Message)
        this.getAllData()
        this.$refs.uploadBasic.clearFiles()
      } else {
        this.$message(e.Message)
      }
    },

    // 添加
    async addUser() {
      this.$router.push('/baojia/cgxqAdd?key=14012')
      return
      // this.editText = false
      // this.form = {}
      // const data = {}

      // this.dialogThead.map(item => { data[item.frepfld] = '' })
      // for (const i in data) {
      //   this.$set(this.form, i, data[i])
      // }

      // this.form.ffax = this.setConfigData.fsetffax
      // setTimeout(() => {
      //   this.$refs['form'].clearValidate()
      // })

      // this.addUserModal = true
    },

    // 修改
    async editUser() {
      const data = this.selectedData[0]

      // if (data && Number(data.fstatus) === 1) {
      //   this.$message({
      //     message: '已审核，不能修改！',
      //     type: 'error'
      //   })
      //   return
      // }
      this.editText = true
      this.form = {}
      if (this.selectedData.length !== 1) {
        this.$message({
          message: '请选中要编辑的一行',
          type: 'error'
        })
        return
      }
      console.log(data, 'data')

      this.$router.push('/baojia/cgxqAdd?key=14012&fid=' + data.fid)

      // this.dialogThead.map(item => { this.$set(this.form, item.frepfld, '') })
      // this.form.fid = 0
      // this.addUserModal = true
      // for (const i in this.form) {
      //   this.form[i] = data[i]
      //   this.dialogThead.map(item => {
      //     if (item.frepmeg === 1 && i === item.frepfld && !data[i]) {
      //       this.form[i] = ''
      //     }
      //   })
      // }

      // if (typeof (this.form.ffax) === 'undefined') {
      //   this.$set(this.form, 'ffax', this.setConfigData.fsetffax)
      // }

      // setTimeout(() => {
      //   this.$refs['form'].clearValidate()
      // })
    },

    async confirm() {
      this.$refs['form'].validate(async(valid) => {
        if (valid) {
          this.loadingForm = true
          try {
            this.form.db = this.globalDb.db
            this.form.opername = opername
            this.form.FRepKey = FRepKey

            const res = await genAdd(this.form)
            if (res.Error === 0) {
              this.loadingForm = false
              this.addUserModal = false
              this.$message({
                message: res.Message,
                type: 'success'
              })

              await this.getAllData()
            } else {
              this.loadingForm = false

              this.$message({
                message: res.Message,
                type: 'error'
              })
            }
          } catch (error) {
            this.loadingForm = false
          }
        } else {
          return false
        }
      })
    },

    async delUser() {
      const data = this.checkData
      if (data.length < 1) {
        this.$message({
          message: '请选中要删除的一行',
          type: 'warning'
        })
        return
      }
      const dataTemp = this.selectedData
      const isFstatus = dataTemp.filter(it => Number(it.fstatus) === 1)

      if (isFstatus.length) {
        this.$message({
          message: '已审核，不能删除！',
          type: 'error'
        })
        return
      }

      this.$confirm('此操作将永久删除, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        cancelButtonClass: 'btn-custom-cancel',
        type: 'warning'
      }).then(async() => {
        const fid = data.join(',')
        const res = await genDel({
          db: this.globalDb.db,
          opername,
          data: this.selectedData,
          fid: fid,
          FRepKey

        })
        if (res.Error === 0) {
          this.$message({
            message: res.Message,
            type: 'success'
          })
          await this.getAllData()
          return
        }
        this.$message({
          message: res.Message,
          type: 'error'
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        })
      })
    },

    // 合计
    getSummaries({ columns, data }) {
      const sums = []
      const arr = []
      this.oriColumnData.forEach((item, itemIndex) => {
        if (item.frepfld && item.frepsum === 1) {
          arr.push(item.frepfld)
        }
      })
      columns.forEach((column, columnIndex) => {
        if (columnIndex === 0) {
          sums[columnIndex] = '合计'
        } else {
          if (arr.indexOf(column.property) >= 0) {
            sums[columnIndex] = this.sumNum(data, column.property).toFixed(2)
          } else {
            sums[columnIndex] = ''
          }
        }
      })
      // 返回一个二维数组的表尾合计
      return sums
    },

    sumNum (list, field) { // DONE
      let sumArr = []
      list.forEach(item => {
        sumArr.push(Number(item[field]))
      })
      if (!sumArr.length) {
        return 0
      }
      let sumList = this.decimal.add(...sumArr)
      return sumList
    },

    // 1—审核，0—反审
    async check(Fstatus) {
      if (!this.checkData.length) {
        this.$message({
          message: '请选择表格行数据',
          type: 'error'
        })
        return
      }
      if (Number(Fstatus) === 1) {
        this.$confirm('是否审核, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          cancelButtonClass: 'btn-custom-cancel',
          type: 'warning'
        }).then(async() => {
          try {
            const res = await checkStatus({
              db: this.globalDb.db,
              opername: decodeURIComponent(this.globalDb.fname),
              loginname: decodeURIComponent(this.globalDb.fname),
              FRepKey,
              Fstatus, // 1—审核，0—反审
              fid: this.checkData.join(',')

            })
            if (res.Error === 0) {
              this.$message({
                message: res.Message,
                type: 'success'
              })
              await this.getAllData()
            } else {
              this.loadingForm = false
              this.$message({
                message: res.Message,
                type: 'error'
              })
            }
          } catch (error) {
            console.log(error)
          }
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消'
          })
        })
      } else {
        try {
          const res = await checkStatus({
            db: this.globalDb.db,
            opername: decodeURIComponent(this.globalDb.fname),
            loginname: decodeURIComponent(this.globalDb.fname),
            FRepKey,
            Fstatus, // 1—审核，0—反审
            fid: this.checkData.join(','),
            appname: ''
          })
          if (res.Error === 0) {
            this.$message({
              message: res.Message,
              type: 'success'
            })
            await this.getAllData()
          } else {
            this.loadingForm = false
            this.$message({
              message: res.Message,
              type: 'error'
            })
          }
        } catch (error) {
          console.log(error)
        }
      }
    },
    // 退审
    async checkTs(Fstatus) {
      if (!this.checkData.length) {
        this.$message({
          message: '请选择表格行数据',
          type: 'error'
        })
        return
      }
      if (Number(Fstatus) === 1) {
        this.$confirm('是否退审, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          cancelButtonClass: 'btn-custom-cancel',
          type: 'warning'
        }).then(async() => {
          try {
            const res = await FstatusTS({
              db: this.globalDb.db,
              opername: decodeURIComponent(this.globalDb.fname),
              loginname: decodeURIComponent(this.globalDb.fname),
              FRepKey,
              Fstatus, // 1—审核，0—反审
              data: this.selectedData,
              fid: this.checkData.join(',')

            })
            if (res.Error === 0) {
              this.$message({
                message: res.Message,
                type: 'success'
              })
              await this.getAllData()
            } else {
              this.loadingForm = false
              this.$message({
                message: res.Message,
                type: 'error'
              })
            }
          } catch (error) {
            console.log(error)
          }
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消'
          })
        })
      } else {
        try {
          const res = await FstatusTS({
            db: this.globalDb.db,
            opername: decodeURIComponent(this.globalDb.fname),
            loginname: decodeURIComponent(this.globalDb.fname),
            FRepKey,
            Fstatus, // 1—审核，0—反审
            data: this.selectedData,
            fid: this.checkData.join(','),
            appname: ''
          })
          if (res.Error === 0) {
            this.$message({
              message: res.Message,
              type: 'success'
            })
            await this.getAllData()
          } else {
            this.loadingForm = false
            this.$message({
              message: res.Message,
              type: 'error'
            })
          }
        } catch (error) {
          console.log(error)
        }
      }
    },
    handleSelectionChange(val) {
      console.log(val, ' val')
      this.checkData = []
      this.selectedData = val
      val.map(it => {
        this.checkData.push(it.fid)
      })
    }

  }
}

</script>
<style lang="scss" scoped>
.config-dialog ::v-deep .el-dialog {
  width: 90%;
}
.config-dialog ::v-deep .el-dialog__body {
  padding: 0 20px;
  height: 600px;
}
.confirm-dialog {
  ::v-deep .el-dialog__body {
    padding: 0 20px;
  }
}
.table-total {
  .sum_footer {
    border-bottom: 1px solid #ddd;
    height: 40px;
    line-height: 40px;
    font-size: 12px;
    overflow: hidden;
    .total {
      float: left;
      width: 32.7%;
      text-align: center;
      // display: inline-block;
      border-right: 2px solid #ddd;
    }
    .mid {
      float: left;
      width: 32%;
      text-align: center;
      // display: inline-block;
      border-right: 2px solid #ddd;
    }
    span.sum {
      float: right;
      // padding: 0 130px;
      // display: inline-block;
      width: 34.6%;
      border-left: 2px solid #ddd;
      text-align: center;

    }
  }
}
</style>
